<html>
	<head>
		<!-- Include Our WebGL JS file -->
		<script src="WebGL.js" type="text/javascript"></script>
		<script>
		
			var GL; 
			var Building;
			
			function Ready(){
				GL = new WebGL("GLCanvas", "FragmentShader", "VertexShader");
				LoadModel("House", function(VerticeMap, Triangles, TextureMap){
					Building = new GLObject(VerticeMap, Triangles, TextureMap, "House.png");
					Building.Pos.Z = 650;
					Building.Scale.X = 0.5;
					Building.Scale.Y = 0.5;
					Building.Scale.Z = 0.5;
					Building.Rotation.Y = 180;
					setInterval(Update, 33);
					document.onkeydown = handleKeyDown;
				});
			}
			function handleKeyDown(event){
				//You can uncomment the next line to find out what keycode goes to which key
				//alert(event.keyCode);
				
				if(event.keyCode == 37)
				{
					//Left Arrow Key
					Building.Pos.X -= 4;
				}
				else if(event.keyCode == 38)
				{
					//Up Arrow Key
					Building.Pos.Y += 4;
				}
				else if(event.keyCode == 39)
				{
					//Right Arrow Key
					Building.Pos.X += 4;
				}
				else if(event.keyCode == 40)
				{
					//Down Arrow Key
					Building.Pos.Y -= 4; 
				}
			}
			function Update(){
				Building.Rotation.Y += 0.3
				GL.GL.clear(16384 | 256);
				GL.Draw(Building);
			}
			
		</script>
	</head>
	<body onload="Ready()">  
	  <canvas id="GLCanvas" width="1280" height="1020">  
	    	Your Browser Doesn't Support HTML5's Canvas.  
	  </canvas>  
	  
	<script id="VertexShader" type="x-shader/x-vertex">  
  
		attribute highp vec3 VertexPosition;
		attribute highp vec2 TextureCoord;
		
		
		uniform highp mat4 TransformationMatrix;
		uniform highp mat4 PerspectiveMatrix;
		
		varying highp vec2 vTextureCoord;
		
		void main(void) {
			gl_Position = PerspectiveMatrix * TransformationMatrix * vec4(VertexPosition, 1.0);
			vTextureCoord = TextureCoord;
		}
	</script>  
	
	<script id="FragmentShader" type="x-shader/x-fragment">  
		varying highp vec2 vTextureCoord;
		
		uniform sampler2D uSampler;
		
		void main(void) {
			highp vec4 texelColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t));
			gl_FragColor = texelColor;
		}     
	</script>  

	
	</body>
</html>